package it.polimi.TravelDream.web.beans;

import it.polimi.TravelDream.ejb.dtos.AddressDTO;
import it.polimi.TravelDream.ejb.dtos.HotelDTO;
import it.polimi.TravelDream.ejb.eaos.HotelList;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name = "hotel")
@RequestScoped
public class HotelBean {

	@EJB
	private HotelList hotelList;
	
	private HotelDTO currentHotel;
	private AddressDTO currentAddress;
	
	public HotelBean() {
		this.currentHotel = new HotelDTO();
		this.currentAddress = new AddressDTO();
	}
	
	public void create() {
		hotelList.add(currentHotel, currentAddress);
	}
	
	public String goToSearchHotel() {
		return "search hotel?faces-redirect=true";
	}
	
	public String goToCreateHotel() {
		return "hotel?faces-redirect=true";
	}
	
	public HotelDTO getcurrentHotel() {
		return currentHotel;
	}
	
	public AddressDTO getCurrentAddress() {
		return currentAddress;
	}
	
	public void setcurrentHotel(HotelDTO current){
		this.currentHotel = current;
	}
	
	public void setCurrentAddress(AddressDTO current){
		this.currentAddress = current;
	}
	
}
